import 'package:json_annotation/json_annotation.dart';
part 'integral_model.g.dart';

@JsonSerializable()
class TaskListResponse {
  int task_status;
  @JsonKey(name: "customer_uid")
  String custom_uid;
  @JsonKey(name: "task_list")
  List<TaskInfoType> task_list;

  TaskListResponse({required this.task_status, required this.task_list, required this.custom_uid});

  factory TaskListResponse.fromJson(Map<String, dynamic> json) =>
      _$TaskListResponseFromJson(json);

  Map<String, dynamic> toJson() => _$TaskListResponseToJson(this);
}

@JsonSerializable()
class TaskInfoType {
  String id;
  String parent_id;
  String task_name;
  String intro;
  String icon;
  String url;
  int integral_type;
  int task_type;
  int task_code;
  String integral_rules;
  String integral;
  int status;
  String valid_at;
  int task_status;

  TaskInfoType(
      {required String this.id,
      required String this.parent_id,
      required String this.task_name,
      required String this.intro,
      required String this.icon,
      required String this.url,
      required int this.integral_type,
      required int this.task_type,
      required int this.task_code,
      required String this.integral_rules,
      required String this.integral,
      required int this.status,
      required String this.valid_at,
      required int this.task_status});

  factory TaskInfoType.fromJson(Map<String, dynamic> json) =>
      _$TaskInfoTypeFromJson(json);

  Map<String, dynamic> toJson() => _$TaskInfoTypeToJson(this);
}

@JsonSerializable()
class TaskScoreResponse {
  int task_type;
  String score;

  TaskScoreResponse({required this.task_type, required this.score});

  factory TaskScoreResponse.fromJson(Map<String, dynamic> json) =>
      _$TaskScoreResponseFromJson(json);

  Map<String, dynamic> toJson() => _$TaskScoreResponseToJson(this);
}

@JsonSerializable()
class TaskSignResponse {
  int status;

  TaskSignResponse({required this.status});

  factory TaskSignResponse.fromJson(Map<String, dynamic> json) =>
      _$TaskSignResponseFromJson(json);

  Map<String, dynamic> toJson() => _$TaskSignResponseToJson(this);
}

@JsonSerializable()
class TaskSignDateResponse {
  @JsonKey(name: "sign_info")
  List<TaskSignDateItem> sign_info;

  TaskSignDateResponse({required this.sign_info});

  factory TaskSignDateResponse.fromJson(Map<String, dynamic> json) =>
      _$TaskSignDateResponseFromJson(json);

  Map<String, dynamic> toJson() => _$TaskSignDateResponseToJson(this);
}

@JsonSerializable()
class TaskSignDateItem {
  String start;
  int day;
  TaskSignDateItem({required this.start, required this.day});

  factory TaskSignDateItem.fromJson(Map<String, dynamic> json) =>
      _$TaskSignDateItemFromJson(json);

  Map<String, dynamic> toJson() => _$TaskSignDateItemToJson(this);
}

@JsonSerializable()
class TaskProgressModel {
  String completed;
  @JsonKey(name: "task_rules")
  List<IntegralRule>? taskRules;

  TaskProgressModel({required this.completed, required this.taskRules});

  factory TaskProgressModel.fromJson(Map<String, dynamic> json) =>
      _$TaskProgressModelFromJson(json);

  Map<String, dynamic> toJson() => _$TaskProgressModelToJson(this);
}

@JsonSerializable()
class IntegralRule {
  String level;
  String value;
  String integral;
  int status; // 级别状态 0-未完成 1-待领取 3-已领取

  IntegralRule(
      {required this.level, required this.integral, required this.status, required this.value});

  factory IntegralRule.fromJson(Map<String, dynamic> json) =>
      _$IntegralRuleFromJson(json);

  Map<String, dynamic> toJson() => _$IntegralRuleToJson(this);
}

// ------------------- 积分 rank -----------------------
@JsonSerializable()
class IntegralRankResponse {
  String count;
  @JsonKey(name: "rank_list")
  List<IntegralRankType> rank_list;
  @JsonKey(name: "user_rank")
  IntegralRankType? user_rank;

  IntegralRankResponse({required this.count, required this.rank_list, required this.user_rank});

  factory IntegralRankResponse.fromJson(Map<String, dynamic> json) =>
      _$IntegralRankResponseFromJson(json);

  Map<String, dynamic> toJson() => _$IntegralRankResponseToJson(this);
}
@JsonSerializable()
class IntegralRankType {
  String avatar;
  String exchange;
  String nickname;
  String rank;
  String integral;
  String user_id;

  IntegralRankType(
      {required String this.avatar,
      required String this.exchange,
      required String this.integral,
      required String this.rank,
      required String this.user_id,
        required String this.nickname});

  factory IntegralRankType.fromJson(Map<String, dynamic> json) =>
      _$IntegralRankTypeFromJson(json);

  Map<String, dynamic> toJson() => _$IntegralRankTypeToJson(this);
}